"""
Provides a simple enumeration class.

Example usage;
    state = enum.Enumeration("not_started", "started", "done")

    s1 = state.not_started
    s2 = state.started
    if s1 != s2:
        print "s1 != s2"

    print s1
    # prints "not_started"

    for s in state:
        print s
"""

class _EnumeratedValue(object):
    def __init__(self, name, value):
        self.name = name
        self.value = value

    def __repr__(self):
        return self.name

class Enumeration(object):
    def __init__(self, *args):
        """Pass strings into __init__ containing the names of the enumerated
        values.
        """
        self.enum_values = []
        for i in range(len(args)):
            enum_value = _EnumeratedValue(args[i], i)
            self.__dict__[args[i]] = enum_value
            self.enum_values.append(enum_value)

    def __iter__(self):
        return self.enum_values.__iter__()

    def __getitem__(self, index):
        return self.enum_values[index]

